package com.c1.client;

import com.c1.client.menu.MenuManager;
import com.c1.client.pan.Pans;

import javax.swing.*;
import java.awt.*;

/**
 * @author zhangjiangnan
 */
public class Frame extends JFrame {
    private static final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    public static int WIDTH = new Double(screen.getWidth()).intValue() * 7 / 8;
    public static int HEIGHT = new Double(screen.getHeight()).intValue() * 7 / 8;
    public static final String LOADING_TITLE = "Loading";

    private Frame() {
        setContentPane(Pans.me());

        setJMenuBar(MenuManager.me().getMenuBar());

        pack();
        setExtendedState(JFrame.NORMAL);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setLocationRelativeTo(null);

        setVisible(true);
    }

    private static volatile Frame me;

    public static Frame me() {
        if (me == null) {
            synchronized (Frame.class) {
                if (me == null) {
                    me = new Frame();
                }
            }
        }
        return me;
    }

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(WIDTH, HEIGHT);
    }
}